import React from 'react' import Link from 'next/link' import fetch from '../../libs/fetch' import { useQuery } from 'react-query' export default () => { const id = typeof window !== 'undefined' ? window.location.pathname.slice(1) : '' const { status, data, error, isFetching } = useQuery( ['team', id], () => fetch('/api/data?id=' + id) ) return (

{id}

{status === 'loading' ? ( 'Loading...' ) : status === 'error' ? ( Error: {error.message} ) : ( <>

forks: {data.forks_count}

stars: {data.stargazers_count}

watchers: {data.watchers}

{isFetching ? 'Background Updating...' : ' '}
)}

Back
) }